package com.itheima.tlias84.mapper;

import com.itheima.tlias84.dto.SelectAllDeptDTO;
import com.itheima.tlias84.entity.Dept;
import com.itheima.tlias84.po.InsertDeptParam;
import com.itheima.tlias84.po.UpdateDeptParam;
import org.apache.ibatis.annotations.*;
//import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper
public interface DeptMapper {



    @Select("select id,name,update_time from dept order by update_time desc ")
    List<SelectAllDeptDTO> selectAll();
    @Insert("insert into dept (name,update_time,create_time) values (#{d.name},#{d.updateTime},#{d.createTime})")
    int insertDept(@Param("d") Dept dept);
    @Delete("delete from dept where id = #{id}")
    int deleteById(@Param("id") Integer id);
    @Select("select id,name,update_time from dept where id = #{id}")
    UpdateDeptParam selectById(@Param("id") Integer id);
//    @Select("select id,name,update_time from dept where id = #{id}")
//    Dept selectByIdA(@Param("id") Integer id);
    @Update("update dept set name = #{dept.name} , update_time = #{dept.updateTime} where id = #{dept.id}")
    int updateById(@Param("dept") Dept dept);

    @Select("select id,name from dept where name = #{name}")
    Dept selectDeptByName(@Param("name") String name);

    int insertDeptA(@Param("d")InsertDeptParam param);

    int batchDelete(List<Integer> ids);
}
